import type { App } from 'vue'
import router from '@/router'
function install(app: App) {
  app.directive('go', {
    mounted: function (el, binding) {
      // 将事件处理函数保存到 el 上
      el._clickHandler = () => {
        router.push(binding.value)
      }
      el.addEventListener('click', el._clickHandler)
    },
    unmounted(el) {
      el.removeEventListener('click', el._clickHandler)
    },
  })
}
export default {
  install,
}
